<template>
  <div>
    <!-- 面包屑 -->
    <el-bread></el-bread>
    <!-- 添加按钮 -->
    <el-button
      @click="addDialog"
      class="btnInfo"
      type="primary"
      size="small"
      plain
      >添加</el-button
    >
    <!-- 列表 -->
    <v-list @edit="edit"></v-list>
    <!-- 弹框 -->
    <v-dialog ref="diaInfo" @cancel="cancel" :addInfo="addInfo"></v-dialog>
  </div>
</template>

<script>
//引入列表组件
import vList from "./list.vue";
import vDialog from "./dialog.vue";
export default {
  data() {
    return {
      addInfo: {
        isAdd: true, //弹框是添加
        isShow: false, //控制弹框的显示隐藏
      },
    };
  },
  methods: {
    addDialog() {
      //打开弹框
      this.addInfo.isShow = true;
      //告诉弹框你是个添加
      this.addInfo.isAdd = true;
    },
    //关闭弹框
    cancel(e) {
      this.addInfo.isShow = e;
    },
    //编辑
    edit(e) {
      //打开弹框
      this.addInfo.isShow = true;
      //告诉弹框你是个编辑
      this.addInfo.isAdd = false;
      this.$refs.diaInfo.lookup(e);
    },
  },
  components: {
    vList,
    vDialog,
  },
};
</script>

<style lang="less" scoped>
.btnInfo {
  margin: 10px 5px;
}
</style>
